<style>
.dyntbl_3 {
    padding-left:30px;
}

.subtitle {
    padding-left:150px;
}

</style>

<legend><<$lng.exportimportproducts>></legend>
<<$lng.inthepast>>
<input type="checkbox" class="checkbox" name="export" <<if $companyprofile.export>>checked <</if>> > <<$lng.exportactivities>>
<input type="checkbox" class="checkbox" name="import" <<if $companyprofile.import>>checked <</if>> > <<$lng.importactivities>>.
<p>

<<dynamictable subtitle="<<$lng.optional>>" name="export" title="<<$lng.exportproducts>>" bottomtext="<<$lng.sponsorhscode>>" buttontitle="<<$lng.addmore>>" headers="<<$lng.productname>>,<<$lng.hscode>>">>
    <<section name=ndx loop=$export_dynamictable>>
    <tr>
        <td><<hsinput value="`$export_dynamictable[ndx].product_name`" id="export[`$export_dynamictable[ndx].rownum-1`]" name="product_export[`$export_dynamictable[ndx].rownum-1`]">></td>
        <td><input type="text" readonly="readonly" style="width:50px;" hscode="<<$export_dynamictable[ndx].hs4>>" name="hs4_export[<<$export_dynamictable[ndx].rownum-1>>]" id="code_export[<<$export_dynamictable[ndx].rownum-1>>]" class="hsdropdown">
        <img name="remove" style="visibility:hidden;" src="site/resources/img/icons/delete.png">
        </td>
<<if ($export_dynamictable[ndx].sponsor_status == "payed")>>
<td style="padding-left:30px;" class="sponsor_payed">
<input type="hidden" name="sponsor_export[<<$export_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_export_month[<<$export_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.payed>></td>
<<else if ($export_dynamictable[ndx].sponsor_status == "ordered")>>
<td style="padding-left:30px;" class="sponsor_ordered">
<input type="hidden" name="sponsor_export[<<$export_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_export_month[<<$export_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.ordered>></td>
<<else if ($export_dynamictable[ndx].sponsor_status == "waiting")>>
<td style="padding-left:30px;" class="sponsor_waiting"><input type="hidden" name="sponsor_export[<<$export_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_export_month[<<$export_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.waiting>>
</td>
<<else>>
        <td style="padding-left:30px;">
        <input onclick="checkboxClicked(this, 6000);" class="checkbox cell_allower sponsor" type="checkbox" name="sponsor_export[<<$export_dynamictable[ndx].rownum-1>>]" value="yes"><label><<$lng.yessponsorhs4>> <span class="sum" ref="hs4sponsor_export_month[<<$export_dynamictable[ndx].rownum-1>>]"></span> <<$lng.monthfor>> <input type="text" prev="1" class="multiplier_freeaugust month" base="6000" value="1" name="hs4sponsor_export_month[<<$export_dynamictable[ndx].rownum-1>>]" style="width:30px;"> <<$lng.month>> (<<$lng.free1month>>)</label>
        </td>
<</if>>
    </tr>
    <</section>>
<</dynamictable>>
<p>
<<dynamictable subtitle="<<$lng.optional>>" name="import" title="<<$lng.importproducts>>" bottomtext="<<$lng.sponsorhscode>>" buttontitle="<<$lng.addmore>>" headers="<<$lng.productname>>,<<$lng.hscode>>">>
    <<section name=ndx loop=$import_dynamictable>>
    <tr>
        <td><<hsinput value="`$import_dynamictable[ndx].product_name`" id="import[`$import_dynamictable[ndx].rownum-1`]" name="product_import[`$import_dynamictable[ndx].rownum-1`]">></td>
        <td><input readonly="readonly" style="width:50px;" hscode="<<$import_dynamictable[ndx].hs4>>" name="hs4_import[<<$import_dynamictable[ndx].rownum-1>>]" id="code_import[<<$import_dynamictable[ndx].rownum-1>>]" class="hsdropdown">
        <img name="remove" style="visibility:hidden;" src="site/resources/img/icons/delete.png">
        </td>
<<if ($import_dynamictable[ndx].sponsor_status == "payed")>>
<td style="padding-left:30px;" class="sponsor_payed">
<input type="hidden" name="sponsor_import[<<$import_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_import_month[<<$import_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.payed>></td>
<<else if ($import_dynamictable[ndx].sponsor_status == "ordered")>>
<td style="padding-left:30px;" class="sponsor_ordered"><input type="hidden" name="sponsor_import[<<$import_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_import_month[<<$import_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.ordered>></td>
<<else if ($import_dynamictable[ndx].sponsor_status == "waiting")>>
<td style="padding-left:30px;" class="sponsor_waiting"><input type="hidden" name="sponsor_import[<<$import_dynamictable[ndx].rownum-1>>]" value="yes">
<input type="hidden" name="hs4sponsor_import_month[<<$import_dynamictable[ndx].rownum-1>>]" value="0">
<<$lng.waiting>></td>
<<else>>
        <td style="padding-left:30px;"><input onclick="checkboxClicked(this, 3000);" class="checkbox cell_allower sponsor" type="checkbox" name="sponsor_import[<<$export_dynamictable[ndx].rownum-1>>]" value="yes"><label><<$lng.yessponsorhs4>><span class="sum" ref="hs4sponsor_import_month[<<$export_dynamictable[ndx].rownum-1>>]"></span><<$lng.monthfor>><input type="text" prev="1" class="multiplier_freeaugust month" base="3000" name="hs4sponsor_import_month[<<$import_dynamictable[ndx].rownum-1>>]" style="width:30px;" value="1"> <<$lng.month>> (<<$lng.free1month>>)</label></td>
<</if>>
    </tr>
    <</section>>
<</dynamictable>>
</p>
<br>
<p>
<h3><<$lng.advertisement>></h3>
<<$lng.placebannerad>><Br>
<table>

<<if ($sponsor.spn_export_rotator.status == "payed")>>
<tr><td>Hungarian exporters page</td><td class="sponsor_payed"><<$lng.payed>></td></tr>
<<else if ($sponsor.spn_export_rotator.status == "ordered")>>
<tr><td>Hungarian exporters page</td><td class="sponsor_ordered"><<$lng.ordered>></td></tr>
<<else if ($sponsor.spn_export_rotator.status == "waiting")>>
<tr><td>Hungarian exporters page</td><td class="sponsor_waiting"><<$lng.waiting>></td></tr>
<<else>>
<tr><td><input onclick="checkboxClicked(this, 30000);" class="checkbox row_allower sponsor" type="checkbox" name="banner_export"><<$lng.hepage>></td><td><<$lng.bannerfor>> <input type="text" name="export_month" class="multiplier month" prev="<<$export_months>>" value="<<$export_months>>" base="30000"> <<$lng.month>></td><td><span ref="export_month" class="sum"></span> HUF</td><td></td></tr>
<</if>>

<<if ($sponsor.spn_import_rotator.status == "payed")>>
<tr><td>Hungarian importers page</td><td class="sponsor_payed"><<$lng.payed>></td></tr>
<<else if ($sponsor.spn_import_rotator.status == "ordered")>>
<tr><td>Hungarian importers page</td><td class="sponsor_ordered"><<$lng.ordered>></td></tr>
<<else if ($sponsor.spn_import_rotator.status == "waiting")>>
<tr><td>Hungarian importers page</td><td class="sponsor_waiting"><<$lng.waiting>></td></tr>
<<else>>
<tr><td><input onclick="checkboxClicked(this, 30000);" class="checkbox row_allower sponsor" type="checkbox" name="banner_import"><<$lng.hipage>></td><td><<$lng.bannerfor>> <input type="text" name="import_month" class="multiplier month" prev="<<$import_months>>" value="<<$import_months>>" base="30000"> <<$lng.month>></td><td><span ref="import_month" class="sum"></span> HUF</td><td></td></tr>
<</if>>

<<if ($sponsor.spn_bl_rotator.status == "payed")>>
<tr><td>Business leads page</td><td class="sponsor_payed"><<$lng.payed>></td></tr>
<<else if ($sponsor.spn_bl_rotator.status == "ordered")>>
<tr><td>Business leads page</td><td class="sponsor_ordered"><<$lng.ordered>></td></tr>
<<else if ($sponsor.spn_bl_rotator.status == "waiting")>>
<tr><td>Business leads page</td><td class="sponsor_waiting"><<$lng.waiting>></td></tr>
<<else>>
<tr><td><input onclick="checkboxClicked(this, 30000);" class="checkbox row_allower sponsor" type="checkbox" name="banner_bl"><<$lng.blpage>></td><td><<$lng.bannerfor>> <input type="text" name="bl_month" class="multiplier month" prev="<<$bl_months>>" value="<<$bl_months>>" base="30000"> <<$lng.month>></td><td><span class="sum" ref="bl_month"></span> HUF</td><td></td></tr>
<</if>>

<<if ($sponsor.spn_service_rotator.status == "payed")>>
<tr><td>Services in Hungary page</td><td class="sponsor_payed"><<$lng.payed>></td></tr>
<<else if ($sponsor.spn_service_rotator.status == "ordered")>>
<tr><td>Services in Hungary</td><td class="sponsor_ordered"><<$lng.ordered>></td></tr>
<<else if ($sponsor.spn_service_rotator.status == "waiting")>>
<tr><td>Services in Hungary</td><td class="sponsor_waiting"><<$lng.waiting>></td></tr>
<<else>>
<tr><td><input onclick="checkboxClicked(this, 30000);" class="checkbox row_allower sponsor" type="checkbox" name="banner_services"><<$lng.svcpage>></td><td><<$lng.bannerfor>> <input type="text" name="services_month" class="multiplier month" prev="1" value="1" base="30000"> <<$lng.month>></td><td><span class="sum" ref="services_month"></span> HUF</td><td></td></tr>
<</if>>

<<if ($sponsor.spn_ha_rotator.status == "payed")>>
<tr><td>Hungarian companies abroad page</td><td class="sponsor_payed"><<$lng.payed>></td></tr>
<<else if ($sponsor.spn_ha_rotator.status == "ordered")>>
<tr><td>Hungarian companies abroad page</td><td class="sponsor_ordered"><<$lng.ordered>></td></tr>
<<else if ($sponsor.spn_ha_rotator.status == "waiting")>>
<tr><td>Hungarian companies abroad page</td><td class="sponsor_waiting"><<$lng.waiting>></td></tr>
<<else>>
<tr><td><input onclick="checkboxClicked(this, 30000);" class="checkbox row_allower sponsor" type="checkbox" name="banner_ha"><<$lng.habroad>></td><td><<$lng.bannerfor>> <input type="text" name="ha_month" class="multiplier month" prev="1" value="1" base="30000"> <<$lng.month>></td><td><span class="sum" ref="ha_month"></span> HUF</td><td></td></tr>
<</if>>

</table>
</p>

<<fileuploader req_minwidth=710 req_minheight=90 req_width=732 value="`$companyprofile.rotator_id`" chgtitle="<<$lng.changebanner>>" req_height=120 uploadfn="uploadSponsorLogo" title="<<$lng.addbanner>>" name="banner_id">>

<p>
<table>
<tr><td><input class="checkbox" type="checkbox" name="accept_tac"></td><td><<$lng.yestou>></td></tr>
<tr><td colspan="2"><<$lng.sendorder>></td></tr>
</table>
</p>
<p>
<<$lng.longterm>>
</p>
<table>
<tr><td>
<<$lng.total>>:
</td><td width="150px;">
<div style="background-color:#DEDEDE;width:auto;"><div style="display:inline;" id="amount"></div> HUF</div>
</td><td>
<div style="display:inline;" id="amount_eur"></div> EUR
</td><td>
<div style="display:inline;" id="amount_usd"></div> USD
</td><td>
<div style="padding-left:1cm;"><<$lng.totaldesc>></div>
</td><td>
<input type="text" name="discount" class="extra discount" style="width:130px;position:relative;top:8px;" onchange="recalculateAmount()">
</td></tr>
</table>

<input type="hidden" name="sponsoration_changed" value="0">

    <<jqbutton type="submit" title="<<$lng.saveexpimp>>" style="width:220px;" onclick="submitExportImport('profile', 'Saving export/import profile, please wait...', this); return false;">>

<script>

var paymentChanged = false;

jQuery("input.payment").click(function() {
    paymentChanged = true;
});

var hsinputplugin = {
    page : "companyprofile",
    hs2service : "geths2",
    hs4service : "geths4fromhs2",
    freetextservice : "gethsdata",
    defaulttext : "enter a product",
    selected : function(hsinputitem, value, code, hunDesc, engDesc) {
        var id = jQuery(hsinputitem).attr("id");
        jQuery("input[id='code_" + id + "']").val(code);
        jQuery("input[id='" + id + "']").val(engDesc);
        return false;
    },
    change : function() {
    }
};

jQuery(".hsinput").hsInput(hsinputplugin);

jQuery("input.multiplier").multiplier({});

jQuery(".fileuploader").fileuploader();

var freeaugust = {
    aftercalc : function(result, base, multiplier) {
        var d = new Date();
        var discount = d.getFullYear() == 2012 && d.getMonth() <= 6;
        if (discount) {
            if (multiplier == 1) { return "Free in August 2012"; }
            return (result - base);
        }
        return result;
    }
};

jQuery("input.multiplier_freeaugust").multiplier(freeaugust);

function submitExportImport(formName, waitMsg, buttonItem) {
    if (sponsorationChanged) { jQuery("input[name='sponsoration_changed']").val(1); } else { jQuery("input[name='sponsoration_changed']").val(0); }
    multiform_saveCurrentTab(jQuery("form[name='profile']"), 1, waitMsg, buttonItem);
}

jQuery("input[type='checkbox'].cell_allower").allower({
    type : "cell"
});

jQuery("input[type='checkbox'].row_allower").allower({
    type : "row"
});

function createLine(tableName, newLineRef, rownum) {
    if (tableName == "export") {
        newLineRef
            .append(jQuery("<td>")
                .append(jQuery("<input>")
                    .attr("id", "export[" + rownum + "]")
                    .attr("type", "text")
                    .attr("name", "product_export[" + rownum + "]")
                    .attr("datavalue", "")
                    .val("")
                    .addClass("hsinput")
                )
                .append(jQuery("<div>")
                    .attr("id", "export[" + rownum + "]_select")
                    .css({
                        display : "none"
                    })
                    .addClass("hsinput_select")
                )
            ).append(jQuery("<td>")
                .append(jQuery("<input>")
                    .attr("type", "text")
                    .attr("readonly", "readony")
                    .attr("id", "code_export[" + rownum + "]")
                    .attr("name", "hs4_export[" + rownum + "]")
                    .css({
                        width : "50px"
                    })
                    .addClass("hsdropdown")
                )
            ).append(jQuery("<td>")
                .css({
                    "padding-left" : "30px"
                })
                .append(jQuery("<input>")
                    .attr("type", "checkbox")
                    .attr("name", "sponsor_export[" + rownum + "]")
                    .attr("plugin_allower_type", "cell")
                    .val("yes")
                    .addClass( "checkbox")
                    .addClass("cell_allower")
                    .addClass("sponsor")
                    .click(function() { checkboxClicked(); })
                ).append(jQuery("<label>")
                    .text("<<$lng.yessponsorhs4>>")
                ).append(jQuery("<span>")
                    .attr("ref", "hs4sponsor_export_month[" + rownum + "]")
                    .addClass("sum")
                ).append(jQuery("<label>")
                    .text(" <<$lng.monthfor>> ")
                ).append(jQuery("<input>")
                    .attr("type", "text")
                    .attr("base", "6000")
                    .attr("name", "hs4sponsor_export_month[" + rownum + "]")
                    .val("1")
                    .css({
                        width : "30px"
                    })
                    .addClass("multiplier_freeaugust")
                    .change(function() {
                        recalculateAmount();
                    })
                    .addClass("month")
                ).append(jQuery("<label>")
                    .text(" <<$lng.month>> (<<$lng.free1month>>)")
                )
        );
    } else if (tableName == "import") {
        newLineRef
            .append(jQuery("<td>")
                .append(jQuery("<input>")
                    .attr("id", "import[" + rownum + "]")
                    .attr("type", "text")
                    .attr("name", "product_import[" + rownum + "]")
                    .attr("datavalue", "")
                    .val("")
                    .addClass("hsinput")
                )
                .append(jQuery("<div>")
                    .attr("id", "import[" + rownum + "]_select")
                    .css({
                        display : "none"
                    })
                    .addClass("hsinput_select")
                )
            ).append(jQuery("<td>")
                .append(jQuery("<input>")
                    .attr("type", "text")
                    .attr("readonly", "readony")
                    .attr("id", "code_import[" + rownum + "]")
                    .attr("name", "hs4_import[" + rownum + "]")
                    .css({
                        width : "50px"
                    })
                    .addClass("hsdropdown")
                )
            ).append(jQuery("<td>")
                .append(jQuery("<input>")
                    .attr("type", "checkbox")
                    .attr("name", "sponsor_import[" + rownum + "]")
                    .attr("plugin_allower_type", "cell")
                    .val("yes")
                    .addClass( "checkbox")
                    .addClass("cell_allower")
                    .click(function() { checkboxClicked(); })
                ).append(jQuery("<label>")
                    .text("<<$lng.yessponsorhs4>>")
                ).append(jQuery("<span>")
                    .attr("ref", "hs4sponsor_import_month[" + rownum + "]")
                    .addClass("sum")
                ).append(jQuery("<label>")
                    .text(" <<$lng.monthfor>> ")
                ).append(jQuery("<input>")
                    .attr("type", "text")
                    .attr("base", "3000")
                    .change(function() {
                        recalculateAmount();
                    })
                    .attr("name", "hs4sponsor_import_month[" + rownum + "]")
                    .val("1")
                    .css({
                        width : "30px"
                    })
                    .addClass("multiplier_freeaugust")
                    .addClass("month")
                ).append(jQuery("<label>")
                    .text(" <<$lng.month>> (<<$lng.free1month>>)")
                )
        );
    }
    jQuery("tr#newline input.cell_allower").allower({
        type : "cell"
    });
    jQuery("tr#newline input.multiplier_freeaugust").multiplier(freeaugust);
    jQuery("tr#newline input.hsinput").hsInput(hsinputplugin);
}

jQuery("table[id='dt_export_table'] tr")
.mouseenter(function() {
    if (jQuery(this).find("input[name^='hs4_export']").val() == "") { return; }
    jQuery(this).addClass("highlighted");
    jQuery(this).find("img[name='remove']").css({
        visibility : "visible"
    });
})
.mouseleave(function() {
    if (jQuery(this).find("input[name^='hs4_export']").val() == "") { return; }
    jQuery(this).removeClass("highlighted");
    jQuery(this).find("img[name='remove']").css({
        visibility : "hidden"
    });
});

jQuery("table[id='dt_import_table'] tr")
.mouseenter(function() {
    if (jQuery(this).find("input[name^='hs4_import']").val() == "") { return; }
    jQuery(this).addClass("highlighted");
    jQuery(this).find("img[name='remove']").css({
        visibility : "visible"
    });
})
.mouseleave(function() {
    if (jQuery(this).find("input[name^='hs4_import']").val() == "") { return; }
    jQuery(this).removeClass("highlighted");
    jQuery(this).find("img[name='remove']").css({
        visibility : "hidden"
    });
});

jQuery("img[name='remove']").click(function() {
    jQuery(this).parents("tr").first().find("input[type='text']").val("");
});

</script>
